import request from '@/utils/request'
import { CommonSearch } from '@/config/list'
import { StarTreeNode } from '@/model/common/tree/model'
import { RouterList, RouterBeanData } from '@/model/system/router/model'

export function loadTreeData () {
  return request<StarTreeNode[]>({
    url: '/router/manage/loadTree'
  })
}

export function loadListByFid (data: CommonSearch) {
  return request<RouterList>({
    url: '/router/manage/loadListByFid',
    data: data,
    method: 'post'
  })
}
export function saveForm (formData: RouterBeanData) {
  return request({
    url: '/router/manage/save',
    data: formData,
    method: 'post'
  })
}

export function loadDataById (id: string) {
  return request({
    url: `/router/manage/loadDataById?id=${id}`
  })
}

export function deleteData (id: string) {
  return request({
    url: `/router/manage/removeData?id=${id}`
  })
}

export function getRoutes () : Promise<any> {
  return request({
    url: '/router/getData',
    method: 'get'
  })
}
